﻿<%@ Page Title="" Language="VB" MasterPageFile="~/App/Master/App.master" AutoEventWireup="false" CodeFile="FollowStat.aspx.vb" Inherits="App_FollowStat" %>


<asp:Content ID="Content1" ContentPlaceHolderID="CphHead" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphMainContent" runat="Server">
    <script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>

    <asp:ScriptManagerProxy runat="server">
        <Scripts>
            <asp:ScriptReference Path="https://www.google.com/jsapi" />
        </Scripts>
    </asp:ScriptManagerProxy>
    <script type="text/javascript">

        google.load('visualization', '1.0', { 'packages': ['geochart'] });
        google.load("visualization", "1", { packages: ["corechart"] });


        $(function () {



            SetUI();
            on_update_panel_server(function () {
                SetUI();
            });

        });

        function SetUI() {

            $(".chosen-select").chosen();

            $("#TxtBeginDate").datepicker({
                dateFormat: 'yy-mm-dd',
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1,
                onClose: function (selectedDate) {
                    $("#TxtEndDate").datepicker("option", "minDate", selectedDate);
                }
            });
            $("#TxtEndDate").datepicker({
                dateFormat: 'yy-mm-dd',
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1,
                onClose: function (selectedDate) {
                    $("#TxtBeginDate").datepicker("option", "maxDate", selectedDate);
                }
            });


        }

        function DrawChartPostSend(o) {
            var data = google.visualization.arrayToDataTable(o.data);

            var options = {
                chartArea: { left: '8%', top: '5%', width: "80%", height: "80%" },
                focusTarget: 'category',
                lineWidth: 3, pointSize: 7, curveType: '',
                hAxis: { slantedText: false, maxAlternation: 1, maxTextLines: 1 },
                series: [
                    { targetAxisIndex: 0, color: '#29ABE2' },
                    { targetAxisIndex: 1, color: '#67B203' }
                ],
                legend: { maxLines: 1, position: 'bottom', alignment: 'start' }
            };

            var chart = new google.visualization.LineChart(document.getElementById('chart_div_post_send'));
            chart.draw(data, options);

        }

        function DrawChartPostSend2(o) {
            var data = google.visualization.arrayToDataTable(o.data);

            var formatter = new google.visualization.NumberFormat({ suffix: '%', fractionDigits: 0 });
            formatter.format(data, 2);


            var options = {
                chartArea: { left: '8%', top: '5%', width: "90%", height: "80%" },
                focusTarget: 'category',
                isStacked: false,
                hAxis: { slantedText: false, minTextSpacing: 0, maxAlternation: 1, maxTextLines: 1 },
                vAxes: [{ textPosition: 'out' }, { textPosition: 'out' }],
                series: [
                    { targetAxisIndex: 0, color: '#ff6a00', type: 'bars' },
                    { targetAxisIndex: 1, color: '#7CCBED', type: 'bars' }
                ],
                legend: { maxLines: 1, position: 'bottom', alignment: 'start' }
            };

            var chart = new google.visualization.ComboChart(document.getElementById('chart_div_post_send2'));
            chart.draw(data, options);

        }

        function DrawChartAutoFollow(o) {
            var data = google.visualization.arrayToDataTable(o.data);

            var options = {
                chartArea: { left: '8%', top: '5%', width: "90%", height: "80%" },
                focusTarget: 'category',
                isStacked: true,
                hAxis: { slantedText: false, minTextSpacing: 0, maxAlternation: 1, maxTextLines: 1 },
                series: [
                    { color: '#C1272D', type: 'line', lineWidth: 3, pointSize: 7, curveType: '' },
                    { color: '#67B203', type: 'bars' },
                    { color: '#FFD203', type: 'bars' }
                ], bar: { groupWidth: '80%' },
                legend: { maxLines: 1, position: 'bottom', alignment: 'start' }

            };

            var chart = new google.visualization.ComboChart(document.getElementById('chart_auto_foll_div'));
            chart.draw(data, options);
        }

        function DrawChartAutoFollow2(o) {
            var data = google.visualization.arrayToDataTable(o.data);

            var options = {
                chartArea: { left: '8%', top: '5%', width: "90%", height: "80%" },
                focusTarget: 'category',
                isStacked: true,
                hAxis: { slantedText: false, minTextSpacing: 0, maxAlternation: 1, maxTextLines: 1 },
                series: [
                    { color: '#C1272D', type: 'line', lineWidth: 3, pointSize: 7, curveType: '' },
                    { color: '#67B203', type: 'bars' },
                    { color: '#FFD203', type: 'bars' }
                ], bar: { groupWidth: '80%' },
                legend: { maxLines: 1, position: 'bottom', alignment: 'start' }

            };

            var chart = new google.visualization.ComboChart(document.getElementById('chart_auto_foll_div2'));
            chart.draw(data, options);
        }

    </script>

    <!-- box 1 -->
    <div class="row-fluid">
        <!-- console -->
        <asp:UpdatePanel ID="UpPConsole" runat="server" UpdateMode="Conditional" class="manage">
            <ContentTemplate>
                <div class="well-manage">
                    <!-- filtri -->
                    <div class="well-manage-sx">
                        <div class="top-bar">
                            follow stat
                        </div>

                        <div class="manage-sx-bottom">
                            <div class="manage-message-head">

                                <asp:TextBox runat="server" ID="TxtBeginDate" CssClass="" Visible="false"></asp:TextBox>
                                <asp:TextBox runat="server" ID="TxtEndDate" CssClass="" Visible="false"></asp:TextBox>


                                <div>
                                    <asp:LinkButton runat="server" CssClass="pg-count" ID="RbtDayAll" Text="always" CommandName="CONSOLE_DAY" CommandArgument="all" />
                                </div>
                                <div>
                                    <asp:LinkButton runat="server" CssClass="pg-count" ID="RbtDay15" Text="15" CommandName="CONSOLE_DAY" CommandArgument="15" />
                                </div>
                                <div>
                                    <asp:LinkButton runat="server" CssClass="pg-count" ID="RbtDay30" Text="30" CommandName="CONSOLE_DAY" CommandArgument="30" />
                                </div>
                                <div>
                                    <asp:LinkButton runat="server" CssClass="pg-count" ID="RbtDay60" Text="60" CommandName="CONSOLE_DAY" CommandArgument="60" />

                                </div>
                                <div>
                                    <asp:LinkButton runat="server" CssClass="pg-count" ID="RbtDay90" Text="90" CommandName="CONSOLE_DAY" CommandArgument="90" />


                                </div>
                                <div><a href="#" class="a-icona5"></a></div>
                            </div>
                            <div class="manage-input">
                                <label>user name</label>
                                <asp:TextBox runat="server" ID="TxtUsername" placeholder="@username" CssClass=""></asp:TextBox>
                                <label>full name</label>
                                <asp:TextBox runat="server" ID="TxtFullname" placeholder=" " CssClass=""></asp:TextBox>

                                <asp:Panel runat="server" ID="PnlSearchAutoFollow">
                                    Status:
                                    <asp:ListBox multiple="" runat="server" CssClass="chosen-select" Width="200px" ID="DdlAutoFollStatus" SelectionMode="Multiple" />
                                    <br />
                                    Hashtag:
                                    <asp:ListBox multiple="" runat="server" CssClass="chosen-select" Width="200px" ID="DdlAutoFollQuery" SelectionMode="Multiple" />
                                    Account:
                                    <asp:ListBox multiple="" runat="server" CssClass="chosen-select" Width="200px" ID="DdlAutoFollProfile" SelectionMode="Multiple" />
                                    <br />
                                    follow bat non follower from  
                                    <asp:TextBox runat="server" ID="TxtNotFollowerFromDay" placeholder="7" Width="50px" CssClass=""></asp:TextBox>
                                    day
                                </asp:Panel>

                            </div>
                            <div class="option-search">
                                <asp:LinkButton runat="server" ID="BtnExport" CssClass="bottone-save" Text="search" />
                            </div>
                        </div>
                    </div>


                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

    <!-- box 2 -->
    <div class="row-fluid">

        <!-- autofollow -->
        <asp:UpdatePanel ID="UpPAutoFollow" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel runat="server" ID="PnlAutoFollow" CssClass="found">

                    <!-- grafici -->
                    <div class="con-grafico">

                        <div class="con-grafico-sx">
                            <div style="width: 100%;">
                                <div class="titolo-sx">
                                    <asp:Label runat="server" ID="LblAutoFollAccount" CssClass="num-titolo" />
                                    new followings
                                </div>
                                <div class="titolo-dxc">
                                    <asp:Label runat="server" ID="LblAutoFollBecFoll" CssClass="num-titolo" />
                                    follow back
                                </div>
                                <div class="titolo-dxc">
                                    <asp:Label runat="server" ID="LblAutoFollUnFoll" CssClass="num-titolo" />
                                    unfollows
                                </div>

                                <%--                                <div class="titolo-sx"><span class="num-titolo">123</span>new followings</div>
                                <div class="titolo-dxc"><span class="num-titolo">8 (14%)</span>follow back</div>
                                <div class="titolo-dxc"><span class="num-titolo">50</span>unfollows</div>--%>
                                <div id="chart_auto_foll_div" style="height: 250px; width: 100%; overflow: hidden;">
                                </div>

                            </div>

                        </div>
                        <div class="con-grafico-dx">
                            <div class="titolo-ico">
                                <div><a href="#" class="a-icona7"></a></div>
                            </div>
                            <%--                                <div id="chart_auto_foll_div2" style="height: 250px; width: 100%; overflow: hidden;">
                                </div>--%>

                            <div id="chart_div_post_send2" style="height: 250px; width: 100%; overflow: hidden;">
                            </div>

                        </div>

                    </div>

                    <!-- query performance -->
                    <div class="top-bar">
                        <div class="top-found">query performance</div>
                        <div class="option-xml-export">
                            <a class="bottone-export" href="#">xls export</a>
                        </div>
                    </div>
                    <div class="well-found">

                        <div class="hash-head">
                            <div class="found-hash-query"><a href="#" class="found-head-title">follow query</a></div>
                            <div class="found-hash-aquired"><a href="#" class="found-head-title">acquired followers</a></div>
                            <div class="found-hash-unfollowed"><a href="#" class="found-head-title-a">unfollowed</a></div>
                            <div class="found-hash-unconversion"><a href="#" class="found-head-title">conversion rate</a></div>

                        </div>

                        <asp:ListView runat="server" ID="ListAutoFollowSummary">
                            <ItemTemplate>

                                <div class="found-hash">
                                    <ul>

                                        <div class="found-hash-query"><%# eval("source_description") %></div>
                                        <div class="found-hash-aquired"><%# eval("count_become_follower") %></div>
                                        <div class="found-hash-unfollowed"><%# Eval("count_unfollower")%></div>
                                        <div class="found-hash-unconversion"><%# UI.Print.Num0(Eval("perc"))%>%</div>

                                    </ul>
                                </div>

                            </ItemTemplate>


                        </asp:ListView>
                        <App:DataPager runat="server" Controlid="ListAutoFollowSummary" PageSize="10" OnPageChanged="SetDataAccountList" />



                    </div>


                    <!-- account status -->
                    <div class="well-connection-following">

                        <div class="top-bar">

                            <div class="top-found">last day:  </div>
                            <asp:Label runat="server" ID="LblFollCounter"></asp:Label> <span style="font-size:10px;">(fatti nelle ultime 24h contando solo quelli fatti con questa procedura, non sono conteggiati quindi quelli fatti da: altri posti di glouk, da altre app, da twitter)</span>
                            <div class="option-xml-export">
                                <a class="bottone-export" href="#">xls export</a>
                            </div>
                        </div>

                        <asp:ListView runat="server" ID="ListAutoFollowAccountStatus">
                            <LayoutTemplate>
                                <div class="hash-head">
                                    <div class="found-hash-followed-user"><a href="#" class="found-head-title">followed user</a></div>
                                    <div class="found-hash-followed-status"><a href="#" class="found-head-title">status</a></div>
                                    <div class="found-hash-followed-update">
                                        <asp:LinkButton ID="LinkButton1" runat="server" CssClass="found-head-title" CommandName="sort" CommandArgument="update_status_date">last update</asp:LinkButton>
                                    </div>
                                    <div class="found-hash-followed-followed">
                                        <asp:LinkButton ID="LinkButton2" runat="server" CssClass="found-head-title" CommandName="sort" CommandArgument="follow_date">followed</asp:LinkButton>
                                    </div>
                                    <div class="found-hash-followed-unfollowed">
                                        <asp:LinkButton ID="LinkButton3" runat="server" CssClass="found-head-title" CommandName="sort" CommandArgument="unfollow_date">unfollowed</asp:LinkButton>
                                    </div>
                                    <div class="found-hash-follow-query"><a href="#" class="found-head-title">follow query</a></div>
                                    <div class="found-hash-follow-query"><a href="#" class="found-head-title"></a></div>
                                </div>
                                <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <div class="found-hash">
                                    <ul>
                                        <div class="found-hash-followed-user"><a href="https://twitter.com/intent/user?user_id=<%# Eval("account_code")%>">@<%# Eval("username")%></a></div>
                                        <div class="found-hash-followed-status-f">
                                            <asp:Label runat="server" Font-Bold="true" ID="LblStatus" Text=''></asp:Label>
                                        </div>
                                        <div class="found-hash-followed-update"><%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("update_status_date")))%></div>
                                        <div class="found-hash-followed-followed"><%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("follow_date")))%></div>
                                        <div class="found-hash-followed-unfollowed"><%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("unfollow_date")))%></div>
                                        <div class="found-hash-follow-query"><%# eval("source_description") %></div>
                                        <div class="found-hash-follow-query">
                                            <div>
                                                <asp:LinkButton runat="server" CssClass="a-icona1 tooltip" title="Follow/unfollow this user" ID="BtnFollow" CommandName="FOLLOW" Text="" />
                                            </div>
                                            <div>
                                                <asp:Label runat="server" ID="LblFollower" CssClass="a-icona2 tooltip" Text="" title="If active, this user is following you"></asp:Label>
                                            </div>
                                        </div>
                                    </ul>
                                </div>
                            </ItemTemplate>
                        </asp:ListView>

                        <App:DataPager runat="server" ID="DPAutoFollowAccountStatus" Controlid="ListAutoFollowAccountStatus" PageSize="20" OnPageChanged="SetDataAccountList"
                            SortField="update_status_date" SortType="Descending" CssActive="found-head-title-a" CssNotActive="found-head-title" />


                        <%--                        <App:DataPager runat="server" Controlid="ListAutoFollowAccountStatus" PageSize="20" OnPageChanged="SetDataAccountList" />--%>

                        <%--                        <div class="found-hash">
                            <ul>

                                <div class="found-hash-followed-user">@Weevo</div>
                                <div class="found-hash-followed-status-f">FOLLOWED</div>
                                <div class="found-hash-followed-update">16/06/14 11:10</div>
                                <div class="found-hash-followed-followed">16/06/14 11:10</div>
                                <div class="found-hash-followed-unfollowed">-</div>
                                <div class="found-hash-follow-query">@skande</div>

                            </ul>
                        </div>

                        <div class="found-hash">
                            <ul>

                                <div class="found-hash-followed-user">@Weevo</div>
                                <div class="found-hash-followed-status-u">UNFOLLOWED</div>
                                <div class="found-hash-followed-update">16/06/14 11:10</div>
                                <div class="found-hash-followed-followed">16/06/14 11:10</div>
                                <div class="found-hash-followed-unfollowed">16/06/14 11:10</div>
                                <div class="found-hash-follow-query">@skande</div>

                            </ul>
                        </div>
                        <div class="found-hash">
                            <ul>

                                <div class="found-hash-followed-user">@Weevo</div>
                                <div class="found-hash-followed-status-b">BECAME FOLLOWER</div>
                                <div class="found-hash-followed-update">16/06/14 11:10</div>
                                <div class="found-hash-followed-followed">16/06/14 11:10</div>
                                <div class="found-hash-followed-unfollowed">16/06/14 11:10</div>
                                <div class="found-hash-follow-query">@skande</div>

                            </ul>
                        </div>

                        <div class="pre-nex">
                            <a class="p-n" href="#">&lt; prev</a>
                            <a class="p-n active" href="#">1</a>
                            <a class="p-n" href="#">2</a>
                            <a class="p-n" href="#">3</a>
                            <a class="p-n" href="#">next &gt;</a>
                            <a class="p-n" href="#">(7)</a>
                            <a class="p-n" href="#"></a>
                        </div>--%>
                    </div>



                    <%--                    <asp:GridView ID="GridFollowStatus" runat="server" Width="100%" AutoGenerateColumns="false" CssClass="summary-results" ShowHeader="true" AllowSorting="true">
                        <Columns>
                            <asp:TemplateField HeaderText="follow account" HeaderStyle-Width="250px">
                                <ItemTemplate>
                                    <asp:HyperLink runat="server" NavigateUrl='<%# "https://twitter.com/" & eval("account_to_foll_username	") %>' Target="_blank">
                                <asp:Label runat="server" Text='<%# eval("account_to_foll_username") %>'></asp:Label>
                                    </asp:HyperLink>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Status" HeaderStyle-Width="150px" ItemStyle-HorizontalAlign="Center" SortExpression="Status_id">
                                <ItemTemplate>
                                    <asp:Label runat="server" Font-Bold="true" ID="LblStatus" Text=''></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Last update" HeaderStyle-Width="150px" ItemStyle-HorizontalAlign="Center" SortExpression="update_status_date">
                                <ItemTemplate>
                                    <asp:Label runat="server" Font-Size="11px" Text='<%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("update_status_date")))%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Foll" HeaderStyle-Width="150px" ItemStyle-HorizontalAlign="Center" SortExpression="follow_date">
                                <ItemTemplate>
                                    <asp:Label runat="server" Font-Size="11px" Text='<%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("follow_date")))%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Unfoll" HeaderStyle-Width="150px" ItemStyle-HorizontalAlign="Center" SortExpression="unfollow_date">
                                <ItemTemplate>
                                    <asp:Label runat="server" Font-Size="11px" Text='<%# MyUI.Print.DateTimeShort(DBase.Conv.DateFromDB(Eval("unfollow_date")))%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="From query" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# eval("source_description") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <AlternatingRowStyle CssClass="AlternatingRow Padding2" />
                        <HeaderStyle CssClass="Header" />
                        <EditRowStyle CssClass="EditRow" />
                        <SelectedRowStyle CssClass="SelectedRow" />
                        <RowStyle CssClass="Row Padding2" />
                    </asp:GridView>
                    <App:DataPager runat="server" ID="pp3" PageSize="5" Controlid="GridFollowStatus" />

                    <asp:GridView ID="GridFollowSummary" runat="server" Width="100%" AutoGenerateColumns="false" CssClass="summary-results" ShowHeader="true" AllowSorting="true" AllowPaging="True">
                        <Columns>
                            <asp:TemplateField HeaderText="auto follow" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# eval("source_description") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="become follow" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# eval("count_become_follower") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="unfollow" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# Eval("count_unfollower")%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="conversione" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# UI.Print.Num0  ( Eval("perc"))%>'></asp:Label>%
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="seg" HeaderStyle-Width="">
                                <ItemTemplate>
                                    <asp:Label runat="server" Text='<%# UI.Print.Num0  ( Eval("seg"))%>'></asp:Label>%
                                </ItemTemplate>
                            </asp:TemplateField>

                        </Columns>
                        <AlternatingRowStyle CssClass="AlternatingRow Padding2" />
                        <HeaderStyle CssClass="Header" />
                        <EditRowStyle CssClass="EditRow" />
                        <SelectedRowStyle CssClass="SelectedRow" />
                        <RowStyle CssClass="Row Padding2" />
                        <PagerTemplate>
                            <App:GridPager ID="GridPager1" runat="server" />
                        </PagerTemplate>
                    </asp:GridView>--%>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>





</asp:Content>
